package invaliddotnetbusinessservicedependency;

import org.eclipse.emf.ecore.EObject;

import org.eclipse.viatra2.emf.incquery.validation.runtime.Constraint;
import org.eclipse.viatra2.emf.incquery.validation.runtime.ValidationUtil;
import org.eclipse.viatra2.emf.incquery.runtime.api.impl.BaseGeneratedMatcherFactory;
import invaliddotnetbusinessservicedependency.InvalidDotNetBusinessServiceDependencyMatch;
import invaliddotnetbusinessservicedependency.InvalidDotNetBusinessServiceDependencyMatcherFactory;
import invaliddotnetbusinessservicedependency.InvalidDotNetBusinessServiceDependencyMatcher;

public class InvalidDotNetBusinessServiceDependencyConstraint extends Constraint<InvalidDotNetBusinessServiceDependencyMatch> {

	private InvalidDotNetBusinessServiceDependencyMatcherFactory matcherFactory;

	public InvalidDotNetBusinessServiceDependencyConstraint() {
		matcherFactory = new InvalidDotNetBusinessServiceDependencyMatcherFactory();
	}

	@Override
	public String getMessage() {
		return "$dotNetService.name$ .Net business service should not depend from $otherService.name$ business service, cause it is implemented with another technology!";
	}

	@Override
	public EObject getLocationObject(InvalidDotNetBusinessServiceDependencyMatch signature) {
		Object location = signature.get("dotNetService");
		if(location instanceof EObject){
			return (EObject) location;
		}
		return null;
	}
	
	@Override
	public int getSeverity() {
		return ValidationUtil.getSeverity("error");
	}
	
	@Override
	public BaseGeneratedMatcherFactory<InvalidDotNetBusinessServiceDependencyMatch, InvalidDotNetBusinessServiceDependencyMatcher> getMatcherFactory() {
		return matcherFactory;
	}
}
